package com.jy.modules.cims.component.common.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jy.modules.cims.data.common.dao.TCMmCreditDealDetailDao;
import com.jy.modules.cims.data.common.dto.TCMmCreditDealDetailDTO;
import com.jy.modules.cims.data.interact.core.loan.response.returnDataList;
import com.jy.platform.core.common.BaseDTO;


/**
 * @classname: TCMmCreditDealDetailService
 * @description: 定义  债权交易流水表明细 实现类
 * @author:  zhiqiang
 */
@Service("com.jy.modules.cims.component.common.service.TCMmCreditDealDetailService")
public class TCMmCreditDealDetailService implements Serializable {

    private static final long serialVersionUID = 1L;
    
	@Autowired
	private TCMmCreditDealDetailDao dao;

	/**
     * @author zhiqiang
     * @description: 分页查询 债权交易流水表明细列表
     * @date 2015-01-07 16:20:26
     * @param searchParams 条件
     * @return
     * @throws
     */ 
	public List<TCMmCreditDealDetailDTO> searchTCMmCreditDealDetailByPaging(Map<String,Object> searchParams) throws Exception {
		List<TCMmCreditDealDetailDTO> dataList =  dao.searchTCMmCreditDealDetailByPaging(searchParams);
		return dataList;
	}
	/**
     * @author zhiqiang
     * @description: 按条件查询债权交易流水表明细列表
     * @date 2015-01-07 16:20:26
     * @param searchParams 条件
     * @return
     * @throws
     */
	public List<TCMmCreditDealDetailDTO> searchTCMmCreditDealDetail(Map<String,Object> searchParams) throws Exception {
	    List<TCMmCreditDealDetailDTO> dataList = dao.searchTCMmCreditDealDetail(searchParams);
        return dataList;
    }
	/**
     * @author zhiqiang
     * @description: 查询债权交易流水表明细对象
     * @date 2015-01-07 16:20:26
     * @param id
     * @return
     * @throws
     */ 
	public TCMmCreditDealDetailDTO queryTCMmCreditDealDetailByPrimaryKey(String id) throws Exception {
		
		TCMmCreditDealDetailDTO dto = dao.findTCMmCreditDealDetailByPrimaryKey(id);
		
		if(dto == null) dto = new TCMmCreditDealDetailDTO();
		
		return dto;
		
	}

	/**
     * @title: insertTCMmCreditDealDetail
     * @author zhiqiang
     * @description: 新增 债权交易流水表明细对象
     * @date 2015-01-07 16:20:26
     * @param dto
     * @return
     * @throws
     */
	@SuppressWarnings("all")
	public Long insertTCMmCreditDealDetail(TCMmCreditDealDetailDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		int count = dao.insertTCMmCreditDealDetail(paramMap);
		
		TCMmCreditDealDetailDTO resultDto = (TCMmCreditDealDetailDTO) paramMap.get("dto");
		Long keyId = resultDto.getId();
		return keyId;
	}
	/**
     * @title: updateTCMmCreditDealDetail
     * @author zhiqiang
     * @description: 修改 债权交易流水表明细对象
     * @date 2015-01-07 16:20:26
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmCreditDealDetail(TCMmCreditDealDetailDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmCreditDealDetail(paramMap);
	}
	
	/**
     * @title: updateTCMmCreditDealDetailByDealCode
     * @description: 通过流水号修改 债权交易流水表明细对象
     * @param paramMap
     * @return
     * @throws
     */
	public int updateTCMmCreditDealDetailByTransferId(TCMmCreditDealDetailDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		 int count = dao.updateTCMmCreditDealDetailByTransferId(paramMap);
		 
		 return count;
	}
	
	/**
     * @title: deleteTCMmCreditDealDetailByPrimaryKey
     * @author zhiqiang
     * @description: 删除 债权交易流水表明细,按主键
     * @date 2015-01-07 16:20:26
     * @param paramMap
     * @throws
     */ 
	public void deleteTCMmCreditDealDetailByPrimaryKey(BaseDTO baseDto,String ids) throws Exception {
		if(StringUtils.isEmpty(ids)) throw new Exception("删除失败！传入的参数主键为null");
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", baseDto);
		paramMap.put("ids", ids);
		dao.deleteTCMmCreditDealDetailByPrimaryKey(paramMap);
	}

}

